<?php

class StudentController extends AppController {
    public $uses = array("Students");
	
	
    public function index() {
			$this->set("pageTitle", "Alunos");
			$this->set("students", $this->Students->all());
    }
	
	public function add() {
		$this->set("pageTitle", "Alunos - Novo");
	}
	
	public function edit($id = null) {
		$this->set("pageTitle", "Alunos - Editar");
		$options = array(
			"conditions" => array(
				"ID_STUDENT" => $id
			)
		);	
		$this->set("student", $this->Students->first($options));
			
	}
	
	public function insert (){
			$data = array(
						"NM_STUDENT" => $this->data['NmStudent'],
						"IS_ACTIVE" => $this->data['IsActive']
			); 
			$this->Students->save($data);
			$this->redirect("/student/");
	}
	
	public function update ($id = null){
		$this->Students->id =  $id;
		
		$data = array(
						"NM_STUDENT" => utf8_decode($this->data['NmStudent']),
						"IS_ACTIVE" => $this->data['IsActive']
		); 
		$this->Students->save($data);
		$this->redirect("/student/");
	}
	
	public function delete($id = null) {
		$this->Students->delete($id);
		$this->redirect("/student/");
	}
	
	
}

?>